#pragma once

#include "data_accessor.h"

namespace details
{
inline void edges_iterator::increment()
{
  if (edge_id_ != INVALID_RAW_EDGE_ID)
  {
    ++edge_id_;
  }
}

inline void edges_iterator::decrement()
{
  if (edge_id_ != INVALID_RAW_EDGE_ID)
  {
    --edge_id_;
  }
}

inline edge_t edges_iterator::dereference() const
{
  details::raw_edge_t * edge = data_accessor_->raw_edge_by_id(edge_id_);
  return edge_t(source_vertex_id_, edge->destination, edge->weight);
}

inline data_accessor_t::data_accessor_t(void * raw_graph_data)
  : vertices_header_(static_cast<details::raw_vertices_header_t *>(raw_graph_data))
{
  edges_header_ = reinterpret_cast<raw_edges_header_t *>(
    &vertices_header_->vertices[vertices_header_->vertices_count]);
}
} // namespace details